import java.util.Comparator;
import java.util.Objects;
import java.util.PriorityQueue;
class Student implements Comparable<Student>{
    public int num;
    public int age;
    public String name;

    public Student(int num, int age, String name) {
        this.num = num;
        this.age = age;
        this.name = name;
    }

    @Override
    public int compareTo(Student o) {
        return this.age - o.age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                '}';
    }
}
public class Main {
    public static void main(String[] args) {
        PriorityQueue<Student> students = new PriorityQueue<>();
        Student s1 = new Student(123,12,"老二");
        Student s2 = new Student(222,8,"老三");
        Student s3 = new Student(333,19,"老大");

        students.offer(s1);
        students.offer(s2);
        students.offer(s3);

        while (!students.isEmpty()) {
            System.out.println(students.poll());
        }
    }
}